package com.frxuexi.park2210.vistor

import androidx.lifecycle.MutableLiveData
import com.frxuexi.lib_base.mvvm.BaseViewModel
import com.frxuexi.lib_base.net.ApiService
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject

@HiltViewModel
class VistorViewModel @Inject constructor(val apiService: ApiService):BaseViewModel() {
    var getVistorsSuc = MutableLiveData<String>()
    var deleteVistorSuc=MutableLiveData<String>()
    var addVisitorSuc=MutableLiveData<String>()

    fun getVistors(map: Map<String,Int>){
        httpRequest({apiService.getVistors(mapToBody(map))},getVistorsSuc::postValue)
    }

    fun deleteVistor(map: Map<String, Int>){
        httpRequest({apiService.deleteVistor(mapToBody(map))},deleteVistorSuc::postValue)
    }

    fun addVisitor(map: Map<String, Any>){
        httpRequest({apiService.addVisitor(mapToBody(map))},addVisitorSuc::postValue)
    }
}